<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>主页</title>
	
	<link rel="stylesheet" type="text/css" href="/static/css/resources/bootstrap.min.css"/>
	<link rel="stylesheet" type="text/css" href="/static/css/stylesheets/index.css"/>
	<script type="text/javascript" src="/static/js/resources/jquery.min.js"></script>
	<script src="/static/js/resources/bootstrap.min.js"></script>
	<script src="/static/js/resources/bootstrapValidator.js"></script>
	
	
	<script type="text/javascript" src="/resources/ueditor.config.js"></script>
	<script type="text/javascript" src="/resources/ueditor.all.js"></script>

</head>
<body>

<div class="nav" th:include="pages/admin/common/nav :: nav"></div>


<div class="container-box">
	<div class="col-md-8 cont-left">
		<!--已关注人状态-->
		<div class="fri-news" id="fri-news" th:each="comment : ${commentPage.getContent()}">
			<div class="news-item">
				<div class="item-top">
					<div class="item-info">
						<span th:text="${comment.getStatusZn()}"></span>
						<div class="btn-group status-button" th:attr="data-status=${comment.getStatus()}">
							<button th:attr="data-id=${comment.getId()}" data-status="freeze"
											type="button" class="btn btn-edefault">冻结
							</button>
							<button th:attr="data-id=${comment.getId()}" data-status="normal"
											type="button" class="btn btn-success">正常
							</button>
						</div>
						<div class="user-name" th:text="${comment.getUser().getNickname()}">AAA</div>
						<div class="create-time" th:text="${#dates.format(comment.getCreateTime(),'yyyy-MM-dd HH:mm:ss')}">
						</div>
						<p class="text" th:utext="${comment.getContext()}"></p>
					</div>
				</div>
			</div>

		</div>
		<ul class="pagination">
			<li th:unless="${commentPage.getNumber()} == 0">
				<a class="arrow" th:href="'/admin/commentList?page=' + ${commentPage.getNumber()} +'&&status=' + ${param.status!=null?param.status[0]:'all'}">&laquo;</a>
			</li>
			<li>
				<a href="javascript:;">当前页面 第<span th:text="${commentPage.getNumber()+1}"></span>页</a>
			</li>
			<li th:unless="${commentPage.getNumber()} == ${commentPage.getTotalPages() -1}">
				<a class="arrow" th:href="'/admin/commentList?page=' + ${commentPage.getNumber() + 2} +'&&status=' + ${param.status!=null?param.status[0]:'all'}">&raquo;</a>
			</li>
			<li>
				<a href="javascript:;">共 <span th:text="${commentPage.getTotalPages()}"></span>页</a>
			</li>
			<li class="goto">
				<a>
					<form action="/admin/commentList" method="get">
						<span>跳转至</span>
						<input onkeyup="value=value.replace(/[^\d]/g,'')" min="0" th:max="${commentPage.getTotalPages()}" type="number" name="page">
						<input class="hide" type="text" name="status" th:value="${param.status!=null?param.status[0]:'all'}">
						<span>页</span>
						<button type="submit">确认跳转</button>
					</form>
				</a>
			</li>
		</ul>
	</div>
		<div class="col-md-4 cont-rit" th:include="pages/admin/common/right-nav :: right">
		</div>
	</div>

	<!--返回顶部-->
	<a href="javascript:void(0);" id="to-top" class="to-top">
		<span class="glyphicon glyphicon-arrow-up top-icon"></span>
	</a>


	<script type="text/javascript">
		$(function () {
			var buttonDiv = $('div.status-button');
			var button = buttonDiv.find('button');
			button.bind('click', function () {
				var _this = $(this);
				var id = _this.attr('data-id');
				var status = _this.attr('data-status');
				$.ajax({
					url: '/admin/setCommentStatus',
					data: {
						'id': id,
						'status': status
					},
					type: 'POST',
					success: function (data) {
						var result = $.parseJSON(data);
						console.info(result);
						var isSuccess = result.isSuccess;
						if (isSuccess) {
							_this.parent().parent().find('span').text(result.other)
						}
						else {
							alert(result.reason);
						}
					}
				});
			});
		});
		/*返回顶部*/
		$(function () {
			var to_top = $("a#to-top"),
					body = $("body,html"),
					body_scrolltop = body.scrollTop(),
					isTop = true;
			to_top.show();
			if (body_scrolltop > 0) {
				to_top.show();
			}
			else {
				to_top.hide();
			}

			to_top.bind("click", function () {
				body.animate({scrollTop: 0}, 200);
				to_top.hide(0, function () {

				});
			});

			$(window).scroll(function () {
				var body_scrolltop = body.scrollTop();
				console.info(body_scrolltop);
				if (body_scrolltop > 0 && isTop == true) {
					isTop = false;
					to_top.fadeIn(200);
				}
				else if (body_scrolltop <= 0) {
					isTop = true;
					to_top.fadeOut(200);
				}
			});
		});
	</script>

</body>
</html>